home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / dfÜ / bbs / aptbbs1 / apt / rexx / aml.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1995-10-10  |  3.6 KB  |  146 lines

  1. /* AML.rexx
  2. **
  3. ** $VER: AML 0.0.1 (26.4.93)
  4. **
  5. ** ARexx program for controlling ApT-BBS by ApT-Design.
  6. **
  7. ** Copyright © 1993 ApT-Design All Rights Reserved,TS,AG
  8. **
  9. ** This script will take in a text file with MCI codes and
  10. ** copy the file to a new one, altering the control codes on
  11. ** the way to their AML equivelents.
  12. **
  13. ** spat "aml.rexx" #?.tpl
  14. **
  15. ** Converted to work with 'spat' by AG,.. Just a quick hack to
  16. ** get you converting those menus fastly.. :)
  17. **
  18. ** Added the 'NL' command to replace \n's correctly within
  19. ** .apt rexx scripts..
  20. **
  21. ** Credit goes to Tom Snow for 99% of this..
  22. **
  23. */
  24.  
  25. /*
  26.  
  27. - stuff to convert -
  28.  
  29. %TC=<colour>.            TEXT COLOUR
  30. %BC=<colour>.            BACKGROUND COLOUR
  31. %CLS.                Clear Screen
  32. %ANSIRESET.            Reset ansi emulation via ESQ[0m
  33. %CURSOR=<0/1>.            Turn cursor off/on
  34. %CURSOR_LEFT=<positions>.    Postion cursor X positions to left.
  35. %CURSOR_RIGHT=<position>.    Position cursor X positions to right.
  36. %CURSOR_UP=<position>.        Position cursor X positions up.
  37. %CURSOR_DOWN=<position>.    Position cursor X positions down.
  38. %UNDERLINE=<0/1>.        Turn Underline Mode off/on.
  39. %RVIDEO=<0/1>.            Turn Reverse Video off/on.
  40. %BOLD=<0/1>.            Turn Bold off/on.
  41. %ITALICS=<0/1>            Turn Italics off/on.
  42. %WAITKEY.            Wait for a keypress.
  43. %NL.              Newline.
  44.  
  45. Allow room for other things such as:-
  46.  
  47. %CREDITS+1.
  48. %CREDITS/20.
  49. %CREDITS=213021.
  50.  
  51. Ahm, and here is the actual table then:-
  52.  
  53. \c{0-7}            =>        %TC={0-7}.
  54. \z{0-7}            =>        %BC={0-7}.
  55. \@            =>        %CLS.
  56. \z0\c7 or \c7\z0    =>        %ANSIRESET./*Not sure so not implmtd*/
  57. \o0            =>        %CURSOR=0.
  58. \o1            =>        %CURSOR=1.
  59. \<{0-9}            =>        %CURSOR_LEFT={0-9}.
  60. \>{0-9}            =>        %CURSOR_RIGHT={0-9}.
  61. \^{0-9}            =>        %CURSOR_UP={0-9}.
  62. \!{0-9}            =>        %CURSOR_DOWN={0-9}.
  63. \u0            =>        %UNDERLINE=0.
  64. \u1            =>        %UNDERLINE=1.
  65. \b0            =>        %BOLD=0.
  66. \b1            =>        %BOLD=1.
  67. \i0            =>        %ITALICS=0.
  68. \i1            =>        %ITALICS=1.
  69. \g{anything}        =>        %WAITKEY.
  70. \n                =>    %NL.
  71. */
  72.  
  73. MCI.1 = 'C'        ;    AML.1 = 'TC'
  74. MCI.2 = 'Z'        ;    AML.2 = 'BC'
  75. MCI.3 = 'O'        ;    AML.3 = 'CURSOR'
  76. MCI.4 = '<'        ;    AML.4 = 'CURSOR_LEFT'
  77. MCI.5 = '>'        ;    AML.5 = 'CURSOR_RIGHT'
  78. MCI.6 = '^'        ;    AML.6 = 'CURSOR_UP'
  79. MCI.7 = '!'        ;    AML.7 = 'CURSOR_DOWN'
  80. MCI.8 = 'U'        ;    AML.8 = 'UNDERLINE'
  81. MCI.9 = 'B'        ;    AML.9 = 'BOLD'
  82. MCI.10= 'I'        ;    AML.10= 'ITALICS'
  83. MCI.11= 'G'        ;    AML.11= 'WAITKEY'
  84. MCI.12= '@'        ;    AML.12= 'CLS'
  85. MCI.13= 'n'        ;    AML.13= 'NL'
  86.  
  87. parse upper arg infile .
  88.  
  89. infile=strip(infile,'B', '"')
  90.  
  91. outfile="ram:stuff/"infile
  92.  
  93. if ~open('in',infile,'R') then DO
  94.     say 'Cannot open 'infile' MCI source file!'
  95.     EXIT
  96. END
  97. if ~open('out',outfile,'W') then DO
  98.     say 'Cannot open AML output file!'
  99.     EXIT
  100. END
  101.  
  102. say 'Working on sourcefile "'infile'" and outputting to "'outfile'"'
  103.  
  104. DO while ~eof('in')
  105.     curline = readln('in')
  106.     newline = ''
  107.     DO charnum=1 to length(curline)
  108.                 curchar=substr(curline,charnum,1)
  109.         if curchar = '\' then DO
  110.             charnum=charnum+1
  111.                     curchar=substr(curline,charnum,1)
  112.             DO tst=1 to 13
  113.                 if upper(curchar) = upper(mci.tst) then DO
  114.                     supplement=''
  115.                     if tst ~>10 then supplement=supplement||substr(curline,charnum+1,1)
  116.                     call swapcode(tst,supplement)
  117.                     newcode=result
  118.                     if tst=11 then charnum=charnum+1
  119.                     charnum=charnum+length(supplement)
  120.                     newline=newline||newcode
  121.                 END
  122.             END
  123.         END
  124.         ELSE newline=newline||curchar
  125.     END
  126.     call writeln('out',newline)
  127. END
  128.  
  129. say 'Reached end!'
  130. EXIT
  131.  
  132.  
  133. /*****************************************************
  134.  * swapcode: Just gets the number of the MCI stem    *
  135.  *           and turns it into a similar AML thingy. *
  136.  *****************************************************/
  137.  
  138. swapcode:
  139. parse upper arg mcicode,magntd
  140.  
  141. if mcicode ~> 10 then return '%'||AML.mcicode||'='||magntd||'.'
  142. return '%'||AML.mcicode||'.'
  143.  
  144. /*Uhm............. well.. */
  145. RETURN /* indeedy! */
  146.